package org.dromara.sms4j.core.factory;

import com.google.api.client.util.Lists;
import org.springframework.beans.factory.InitializingBean;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * 一次性加载所有的配置
 *
 * @author: easyorder
 * @date: 2023/5/24 21:52
 * @version: 1
 */
public class MultipleSmsFactoryRegisterAll implements InitializingBean {
    public static final AtomicBoolean initialized = new AtomicBoolean(false);

    @Override
    public void afterPropertiesSet() throws Exception {
        if (initialized.compareAndSet(false, true)) {
            //从数据库获取所有的sms服务的相关配置
            List servers = Lists.newArrayList();
            for (Object server : servers) {
                //服务起的识别Key
                String key = null;
//                server的对象为服务的配置类TencentConfig，AlibabaConfig,CloopenConfig 等等其他服务类型配置
                MultipleSmsFactory.register(key,server);
            }
        }
    }
}
